// 节流
const throttle = (func, delay = 2000) => {
  let prev = Date.now();
  return () => {
    let context = this;
    let args = arguments;
    let now = Date.now();
    if (now - prev >= delay) {
      func.apply(context, args);
      prev = Date.now();
    }
  }
}

// 检测登录状态
const checktoken = (token, callback) => {
  if (!token) {
    return wx.redirectTo({
      url: '../login/login',
    })
  } else {
    callback()
  }
}

module.exports = {
  throttle,
  checktoken
}
